﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace 药品信息管理
{
    public partial class YP_GYS : Form
    {
        public YP_GYS()
        {
            InitializeComponent();
        }


        public void YP_GYS_Load(object sender, EventArgs e)
        {
            db db2 = new db();
            string str = @"SELECT BM 编码, DH 助记符, MC 名称, ZCBM 注册编码, DZ 地址, LXR 联系人, TEL 电话, FAX 传真, POST 邮箱地址, JYXKZ 经营许可证, EMAIL 电子邮件, URL 网址 FROM YK_ZDGYS order by bm";
            dataGridView1.DataSource=db2.sqldt(str);
            
        }
        

      private void buttonItem2_Click(object sender, EventArgs e)
        {
            db db1 = new db();
            db1.DataToExcel(dataGridView1);
        }

        private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            if (dataGridView1.CurrentRow.Cells[0].Value.ToString() != "")
            {
                SQL.Gv_bm = dataGridView1.CurrentRow.Cells[0].Value.ToString();
            }

            GYS_WRITE GYW = new GYS_WRITE();
            GYW.ShowDialog(); 
        }

        private void textBoxItem1_InputTextChanged(object sender)
        {
            try
            {
                foreach (DataGridViewRow R2 in dataGridView1.Rows)
                {
                    if (R2.Cells[0].Value.ToString() == textBoxItem1.Text)
                    {
                        R2.Selected = false;
                    }
                    else { R2.Selected =true ; }
                }
            }
            catch { };
        }

        private void buttonItem4_Click(object sender, EventArgs e)
        {
            GYS_WRITE GYW = new GYS_WRITE();
            GYW.ShowDialog();
            
            
        }

        private void buttonItem5_Click(object sender, EventArgs e)
        {
            db db3 = new db();
            if (MessageBox.Show("确定要删除该供应商信息吗？", "删除提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
            {
                db3.sqlcmd("delete from YK_ZDGYS WHERE bm='" + dataGridView1.CurrentRow.Cells[0].Value.ToString() + "'");
            }
            string str = @"SELECT BM 编码, DH 助记符, MC 名称, ZCBM 注册编码, DZ 地址, LXR 联系人, TEL 电话, FAX 传真, POST 邮箱地址, JYXKZ 经营许可证, EMAIL 电子邮件, URL 网址 FROM YK_ZDGYS order by bm";
            dataGridView1.DataSource = db3.sqldt(str);
        }
    }
 }
